﻿#pragma once

#ifndef SCH_LEG_H
#define SCH_LEG_H

#include "BasAirport.h"
#include "BasPattern.h"
#include "ICPUtility.h"

class BasAircraft;

class SchLeg {
  private:
    static int _countId;
    int _id;

    LEGTYPE _legType;
    string _flightId;
    string _flightNo;
    BasAirport* _dep;
    BasAirport* _arr;
    string _voyage;
    time_t _std;
    time_t _sta;
    time_t _date;
    string _acType;
    string _acTypeCrew;
    string _acReg;
    D_OR_I _dori;
    time_t _flyTime;
    string _crewOwner;
    P_OR_C _porc;
    time_t _signIn;           // 签入时间
    time_t _signOut;          // 签出时间
    time_t _endRestTime;      // 休息结束
    time_t _bgnRestTime;      // 休息开始
    REST_LEVEL _restLevel;    // 休息区等级
    vector<string> _baseList; // 可指派的基地（空值代表不约束）
    bool _isBestAirline;      // 是否精品航线
    bool _isZWWW;             // 是否涉疆航线
    string _flightFlag;       // A-航班；C-本场
    string _flightType;       // 航班性质，H表示货运航班

    bool _isTarget;

    vector<SchLeg*> _outLegList;

    double _costCover;
    double _dualCover;
    bool _fixedLP;

  public:
    SchLeg(LEGTYPE legType, string flightId, string flightNo, BasAirport* dep, BasAirport* arr, time_t std, time_t sta,
           time_t date, string acType, string acTypeCrew, string acReg, D_OR_I dori, P_OR_C porc, time_t flyTime,
           REST_LEVEL restLevel, string crewOwner);
    ~SchLeg();

    void setId(int id) { _id = id; }
    void setStd(time_t std) { _std = std; }
    void setSta(time_t sta) { _sta = sta; }

    void pushOutLeg(SchLeg* leg) { _outLegList.push_back(leg); }
    void setIsTarget(bool flag) { _isTarget = flag; }
    void setCostCover(double cost) { _costCover = cost; }
    void setDualCover(double dual) { _dualCover = dual; }
    void resetCover();
    void print();
    void setFixedLP(bool fix) { _fixedLP = fix; }

    int getId() { return _id; }
    LEGTYPE getLegType() { return _legType; }
    string getFlightId() { return _flightId; }
    string getFlightNo() { return _flightNo; }
    BasAirport* getDep() { return _dep; }
    BasAirport* getArr() { return _arr; }
    string getVoyage() { return _voyage; }
    time_t getStd() { return _std; }
    time_t getSta() { return _sta; }
    time_t getDate() { return _date; }
    string getAcType() { return _acType; }
    string getAcTypeCrew() { return _acTypeCrew; }
    string getAcReg() { return _acReg; }
    D_OR_I getDorI() { return _dori; }
    bool isDomestic() { return _dori == D; }
    P_OR_C getPorC() { return _porc; }
    time_t getFlyTime() { return _flyTime; }
    string getCrewOwner() { return _crewOwner; }
    void setBaseList(vector<string> value) { _baseList = value; }
    vector<string> getBaseList() { return _baseList; }
    void setBestAirline(bool value) { _isBestAirline = value; }
    bool getBestAirline() { return _isBestAirline; }
    void setSignIn(time_t value) { _signIn = value; }
    time_t getSignIn() { return _signIn; }
    void setSignOut(time_t value) { _signOut = value; }
    time_t getSignOut() { return _signOut; }
    void setEndRestTime(time_t value) { _endRestTime = value; }
    time_t getEndRestTime() { return _endRestTime; }
    void setBgnRestTime(time_t value) { _bgnRestTime = value; }
    time_t getBgnRestTime() { return _bgnRestTime; }
    void setIsZWWW(bool value) { _isZWWW = value; }
    bool getIsZWWW() { return _isZWWW; }
    void setFlightFlag(string value) { _flightFlag = value; }
    string getFlightFlag() { return _flightFlag; }
    void setFlightType(string value) { _flightType = value; }
    string getFlightType() { return _flightType; }

    bool isDeadHead() { return _legType == LEG_VB || _legType == LEG_VA; }
    REST_LEVEL getRestLevel() { return _restLevel; }
    vector<SchLeg*> getOutLegList() { return _outLegList; }
    bool isTarget() { return _isTarget; }
    double getCostCover() { return _costCover; }
    double getDualCover() { return _dualCover; }
    bool fixedLP() { return _fixedLP; }

    static bool cmpByTime(SchLeg* a, SchLeg* b);
};

#endif
